import logging

# 配置日志打印级别
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)


# 定义城市服务
class CityWeatherServer:
    # 模拟城市的天气数据
    CITY_WEATHER_DATA = {
        "北京": {"condition": "晴", "temperature": 25, "humidity": 40},
        "上海": {"condition": "多云", "temperature": 27, "humidity": 60},
        "广州": {"condition": "雨", "temperature": 30, "humidity": 80},
        "深圳": {"condition": "多云", "temperature": 29, "humidity": 70},
        "杭州": {"condition": "晴", "temperature": 26, "humidity": 50},
    }

    async def get_city_weather(self, city: str) -> str:
        logger.info(f"获取天气信息: {city}")
        if city in self.CITY_WEATHER_DATA:
            weather = self.CITY_WEATHER_DATA[city]
            return f"{city} : {weather['condition']} , {weather['temperature']} °C,湿度 {weather['humidity']} %"
        else:
            return f"抱歉,未找到 {city} 的天气信息"

    async def get_city_list(self) -> list:
        logger.info(f"获取所有的城市信息")
        city_list = []
        for city in self.CITY_WEATHER_DATA:
            city_list.append(city)
        return city_list

    async def get_city_detail(self, city: str) -> str:
        logger.info(f"获取指定城市的信息: {city}")

        if city in await self.get_city_list():
            return f"{city} : 一个风景秀丽的城市，你值得去玩一把"
        else:
            return f"抱歉,未找到 {city} 的城市信息"
